package com.xhwl.data.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xhwl.common.pojo.ResultJson;
import com.xhwl.common.pojo.cent.sdata.Project;
import com.xhwl.common.pojo.cent.sdata.Scene;
import com.xhwl.data.pojo.dto.SceneQueryPageDTO;
import com.xhwl.data.service.ISceneService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class SceneController {

    @Autowired
    private ISceneService sceneService;

    @RequestMapping(value = "/scene/page")
    public ResultJson page(@RequestBody SceneQueryPageDTO sceneQueryPageDTO) {
        Page page = sceneQueryPageDTO.getPage() == null ? new Page() : sceneQueryPageDTO.getPage();
        Page<Scene> scenePage = sceneService.page(sceneQueryPageDTO.getScene(), page);
        return ResultJson.success(scenePage);
    }

    @RequestMapping(value = "/scene/list")
    public ResultJson list(@RequestBody SceneQueryPageDTO sceneQueryPageDTO) {
        List<Scene> result = sceneService.findList(sceneQueryPageDTO);
        return ResultJson.success(result);
    }

    @RequestMapping(value = "/scene/projectList")
    public ResultJson projectList(@RequestParam Integer id) {
        List<Project> result = sceneService.projectList(id);
        return ResultJson.success(result);
    }

    @RequestMapping(value = "/scene/project/page")
    public ResultJson projectPage(@RequestBody SceneQueryPageDTO sceneQueryPageDTO) {
        Page page = sceneQueryPageDTO.getPage() == null ? new Page() : sceneQueryPageDTO.getPage();
        Page<Project> scenePage = sceneService.projectPage(sceneQueryPageDTO.getScene(), page);
        return ResultJson.success(scenePage);
    }
}
